package com.lindroy.androidplayer.ui.adapter

import androidx.lifecycle.LifecycleOwner
import com.lindroy.androidplayer.base.adapter.BaseListAdapter
import com.lindroy.androidplayer.databinding.LibraryItemBinding
import com.lindroy.androidplayer.viewmodels.LibraryItemViewModel

/**
 * @author Lin
 * @date 2022/3/3
 * @function 开源许可
 */
class LibraryAdapter(owner: LifecycleOwner) :
    BaseListAdapter<LibraryItemViewModel, LibraryItemBinding>(owner) {

    override fun LibraryItemBinding.onBindViewHolder(item: LibraryItemViewModel, position: Int) {
        vm = item
    }

    override fun artItemsTheSame(
        oldItem: LibraryItemViewModel,
        newItem: LibraryItemViewModel
    ): Boolean = oldItem.name == newItem.name

    override fun areContentsTheSame(
        oldItem: LibraryItemViewModel,
        newItem: LibraryItemViewModel
    ) = oldItem.name == newItem.name
}